package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.BuyerTicket;
import cn.icanci.ladybird.dao.BuyerTicketDao;
import cn.icanci.ladybird.service.BuyerTicketService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (BuyerTicket)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:33:38
 */
@Service("buyerTicketService")
public class BuyerTicketServiceImpl implements BuyerTicketService {
    @Resource
    private BuyerTicketDao buyerTicketDao;

    /**
     * 通过ID查询单条数据
     *
     * @param buyerTicketId 主键
     * @return 实例对象
     */
    @Override
    public BuyerTicket queryById(Long buyerTicketId) {
        return this.buyerTicketDao.queryById(buyerTicketId);
}

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BuyerTicket> queryAllByLimit(int offset, int limit) {
        return this.buyerTicketDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param buyerTicket 实例对象
     * @return 实例对象
     */
    @Override
    public BuyerTicket insert(BuyerTicket buyerTicket) {
        this.buyerTicketDao.insert(buyerTicket);
        return buyerTicket;
    }

    /**
     * 修改数据
     *
     * @param buyerTicket 实例对象
     * @return 实例对象
     */
    @Override
    public BuyerTicket update(BuyerTicket buyerTicket) {
        this.buyerTicketDao.update(buyerTicket);
        return this.queryById(buyerTicket.getBuyerTicketId());
    }

    /**
     * 通过主键删除数据
     *
     * @param buyerTicketId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long buyerTicketId) {
        return this.buyerTicketDao.deleteById(buyerTicketId) > 0;
    }
}